﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// 使用OleDb连接数据库
using System.Data.OleDb;

namespace 实验7_学生成绩管理系统
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            string username = System.AppDomain.CurrentDomain.GetData("username").ToString();
            this.Text = "欢迎您！" + username;
            OleDbCommand cmd = OleDbUtil.getOleDbCommand();
            cmd.CommandText = "select * from LoginLog where username = ?";
            OleDbParameter param = new OleDbParameter();
            param.Value =username;
            cmd.Parameters.Add(param);

            OleDbDataAdapter adapter = new OleDbDataAdapter();
            adapter.SelectCommand = cmd;

            DataTable dt = new DataTable();
            adapter.Fill(dt);

            BindingSource bs = new BindingSource();
            DataView dv = dt.DefaultView;
            bs.DataSource = dv;
            this.dataGridView1.DataSource = bs;
        }
    }
}
